﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using GH.BLL;

public partial class ajaxGetJason : GH.Web.BasePage.PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            DataSet dsRecord = new DataSet();
            DataTable dtRecord = new DataTable();
            JSON_Class jason = new JSON_Class();
            string strWhere = string.Empty;
            string strTransFlg = Request["TransFlg"].ToString();
            switch (strTransFlg)
            {
                //单位列表
                case "UionList":
                    Union unitInfo = new Union();
                    strWhere += " 1=1";
                    if (Request["FromSource"] != null)
                    {
                        //根据业务分类判断权限
                        if (Request["FromSource"].ToString() == "Organizations")
                        {
                            //汇总权限
                            if (!GetRight(301))
                            {
                                strWhere += "AND  ID=" + this.Session["Union"].ToString();
                            }
                        }
                    }
                    dsRecord = unitInfo.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //部门列表
                case "DepartmentList":
                    DepartMent departMInfo = new DepartMent();
                    strWhere = "单位ID=" + Request["UionID"].ToString();
                    dsRecord = departMInfo.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //角色列表
                case "RoleList":
                    Rights bllRights = new Rights();
                    dtRecord = bllRights.GetRoleList();
                    Response.Write(jason.CreateJsonParameters(dtRecord));
                    break;
                //班组列表
                case "GroupList":
                    Group bllGroup = new Group();
                    strWhere = "单位ID=" + Request["UionID"].ToString();
                    dsRecord = bllGroup.GetAllList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //工会组织机构统计表 
                case "OrganizationSumirise":
                    ReportOrganization bllReportOrganization = new ReportOrganization();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会组织机构统计表.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllReportOrganization.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;

                //互助员工统计 
                case "MutualMemberSumirise":
                    GH.BLL.MutualMember bllMutualMember = new MutualMember();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  互助员工统计表.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "Search")
                    {
                        string theUnionID = Request["theUnoinID"].ToString();
                        string theName = Request["theName"].ToString();

                        if (theUnionID != "0")
                        {
                            strWhere += " AND  互助员工统计表.单位=" + theUnionID;
                        }
                        if (theName.Trim().Length > 0)
                        {
                            strWhere += " AND  互助员工统计表.姓名 like '%" + theName.Trim() + "%'";
                        }
                    }
                    dsRecord = bllMutualMember.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //疗养情况 
                case "RecuperateCondationSumirise":
                    string theDate = Request["theDate"].ToString();
                    GH.BLL.RecuperateCondation bllRecuperateCondation = new RecuperateCondation();
                    strWhere += "  年份='" + theDate + "'";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  单位=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllRecuperateCondation.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //会员取得

                //疗养情况 
                case "RecuperatePlan":
                    string RecuperatePlantheDate = Request["theDate"].ToString();
                    GH.BLL.RecuperatePlan bllRecuperatePlan = new RecuperatePlan();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllRecuperatePlan.GetList(strWhere,RecuperatePlantheDate);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //会员取得
                case "VipMember":
                    VipMember bllVipMember = new VipMember();
                    //strWhere = "单位ID=" + this.Session["UnionSelect"];
                    strWhere += " WHERE 1=1";
                    if (Request["FromSource"] != null)
                    {
                        //根据业务分类判断权限
                        if (Request["FromSource"].ToString() == "Organizations"
                            || Request["FromSource"].ToString() == "UnionBuiltHome"
                            )
                        {
                            //汇总权限
                            if (!GetRight(301))
                            {
                                strWhere += " AND  会员基本信息.单位=" + this.Session["Union"].ToString();
                            }
                        }
                        if (Request["UnionId"].ToString() != "")
                        {
                            strWhere += " AND  会员基本信息.单位=" + Request["UnionId"].ToString();
                        }

                    }

                    dsRecord = bllVipMember.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;

                //单一会员取得
                case "theVipMember":
                    VipMember thebllVipMember = new VipMember();
                    int vipMemberID = Convert.ToInt32(Request["id"]);
                    strWhere += " WHERE 会员基本信息.ID=" + vipMemberID;

                    dsRecord = thebllVipMember.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                case "Class":
                    GH.BLL.User bllOption = new User();
                    dsRecord = bllOption.GetOptionList(Request["Style"].ToString());
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //法律援助 
                case "LegalAid":
                    GH.BLL.LegalAid bllLegalAid = new LegalAid();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        strWhere += " AND  工会年度法律援助统计表.年份='" + Request["SelectYear"].ToString() + "'";
                        dsRecord = bllLegalAid.GetListSum(strWhere);
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会年度法律援助统计表.单位=" + this.Session["UnionSelect"].ToString();
                        strWhere += " AND  工会年度法律援助统计表.年份='" + Request["SelectYear"].ToString() + "'";
                        dsRecord = bllLegalAid.GetList(strWhere);
                    }

                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //厂务公开民主管理工作统计表 
                case "DemocraticManagement":
                    GH.BLL.DemocraticManagement bllDemocraticManagement = new DemocraticManagement();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        strWhere += " AND  厂务公开民主管理统计表.年份='" + Request["SelectYear"].ToString() + "'";
                        dsRecord = bllDemocraticManagement.GetListSum(strWhere);
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  厂务公开民主管理统计表.单位=" + this.Session["UnionSelect"].ToString();
                        strWhere += " AND  厂务公开民主管理统计表.年份='" + Request["SelectYear"].ToString() + "'";
                        dsRecord = bllDemocraticManagement.GetList(strWhere);
                    }
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //劳动模范
                case "ModelWorker1":
                    GH.BLL.ModelWorker bllModelWorker1 = new ModelWorker();
                    strWhere += "  1=1";
                    strWhere += " AND  劳动模范.年份='" + Request["SelectYear"].ToString() + "'";
                    dsRecord = bllModelWorker1.GetList1(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //集体奖
                case "ModelWorker2":
                    GH.BLL.ModelWorker bllModelWorker2 = new ModelWorker();
                    strWhere += "  1=1";
                    strWhere += " AND  先进集体统计表.年份='" + Request["SelectYear"].ToString() + "'";
                    dsRecord = bllModelWorker2.GetList2(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //各类员工入会率统计
                case "MemberShipRate":
                    GH.BLL.MemberShipRate bllMemberShipRate = new MemberShipRate();
                    string MemberShipRatetheYear = Request["theYear"].ToString();
                    strWhere = "1=1 ";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllMemberShipRate.GetList(strWhere, MemberShipRatetheYear);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                    break;
                //工会建家统计表  
                case "UnionBuiltHome":
                    UnionBuiltHome bllUnionBuiltHome = new UnionBuiltHome();
                    strWhere += "  1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        strWhere += " AND  工会建家统计表.年份='" + Request["SelectYear"].ToString() + "'";
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会建家统计表.单位=" + this.Session["UnionSelect"].ToString();
                        strWhere += " AND  工会建家统计表.年份='" + Request["SelectYear"].ToString() + "'";
                    }
                    dsRecord = bllUnionBuiltHome.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //聘用各类劳务人员入会率统计表
                case "EmployMemberShipRate":
                    GH.BLL.EmployMemberShipRate bllEmployMemberShipRate = new EmployMemberShipRate();
                    string EmployMemberShipRatetheYear = Request["theYear"].ToString();
                    strWhere = " 1=1";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  工会单位信息.ID=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllEmployMemberShipRate.GetList(strWhere,EmployMemberShipRatetheYear);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //工会建家统计表  
                case "LeaderSummrise":
                    LeaderSummrise bllLeaderSummrise = new LeaderSummrise();
                    string theYear = Request["theYear"].ToString();
                    strWhere += "  年份='" + theYear + "' ";
                    if (Request["RightsFlg"].ToString() == "Summary")
                    {
                        //strWhere += " AND  会员基本信息.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    else if (Request["RightsFlg"].ToString() == "SELECT")
                    {
                        strWhere += " AND  专职工会干部统计表.单位=" + this.Session["UnionSelect"].ToString();
                    }
                    dsRecord = bllLeaderSummrise.GetList(strWhere);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
                //各级工会组织、专职工会干部、工会干部培训统计
                case "LeaderTrain":
                    LeaderTrain bllLeaderTrain = new LeaderTrain();
                    string CurrentYear = Request["theYear"].ToString();
                    if (Request["RightsFlg"].ToString() == "1")
                    {
                        //strWhere += " AND  工会组织干部培训统计表.年份=" + CurrentYear;
                    }
                    else
                    {
                        strWhere += " AND  工会单位信息.ID=" + this.Session["Union"].ToString();
                        //strWhere += " AND  工会组织干部培训统计表.年份=" + CurrentYear;

                    }
                    dsRecord = bllLeaderTrain.GetList2(strWhere, CurrentYear);
                    Response.Write(jason.CreateJsonParameters(dsRecord.Tables[0]));
                    break;
            }

        }
        catch
        {
            Response.Write("NG");
        }
        Response.Flush();
        Response.End();
    }
}

